import 'dart:math';

import 'package:flutter/material.dart';
import 'dart:ui' as ui;


class TabIndicator extends Decoration {
  TabIndicator(this.image);
  ui.Image image = null;

  @override
  BoxPainter createBoxPainter([onChanged]) {
    return _TabIndicatorPainter(image);
  }
}

class _TabIndicatorPainter extends BoxPainter {

  _TabIndicatorPainter(this.image);
  ui.Image image = null;

  @override
  void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) {
    final Rect bounds = offset & configuration.size;
    _drawDecoration(canvas, bounds);
  }

  void _drawDecoration(Canvas canvas, Rect bounds) {
    // if (image != null) {
      // double left = bounds.center.dx - image.width / 2;
      // double top = bounds.bottom;
      // var dpr = ui.window.devicePixelRatio;
      // canvas.scale(dpr, dpr);
      // canvas.drawImage(image, Offset(left, top), Paint());
      Paint paint = new Paint()
      ..color = Colors.red
      ..strokeWidth = 4.0
      ..style = PaintingStyle.stroke;
      Rect t = bounds;
      t = t.translate(0, 4);
      canvas.drawArc(t, pi/4, pi/2, false, paint);
    // }
  }
}